﻿Imports BUS
Imports DTO


Public Class MH_TuyChonBaoCaoBDMH

    Private Sub btnHuy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHuy.Click
        Me.Close()
    End Sub

    Private Sub MH_TuyChonBaoCaoBDMH_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Load danh sách lớp
        Dim lopBUS As New LopBUS
        Dim dsL As New List(Of LopDTO)
        dsL = lopBUS.LayDanhSach()
        cboLop.DataSource = dsL
        cboLop.DisplayMember = ("TenLop")
        cboLop.ValueMember = ("MaLop")
        'Load danh sách lớp
        Dim mhBUS As New MonHocBUS
        Dim dsMH As New List(Of MonHocDTO)
        dsMH = mhBUS.LayDanhSach()
        cboMon.DataSource = dsMH
        cboMon.DisplayMember = ("TenMon")
        cboMon.ValueMember = ("MaMon")
        'Load danh sách học kỳ
        Dim hkBUS As New HocKyBUS
        Dim dtHK As New DataTable
        dtHK = hkBUS.LayBang()
        cboHocKy.DataSource = dtHK
        cboHocKy.DisplayMember = ("HocKy")
        cboHocKy.ValueMember = ("MaHocKy")
    End Sub

    Private Sub btnLayBC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLayBC.Click
        'Khởi tạo báo cáo
        Dim bc As New BC_BangDiemMonHoc()
        Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
        For Each tbCurrent In bc.Database.Tables
            tliCurrent = tbCurrent.LogOnInfo
            With tliCurrent.ConnectionInfo
                .ServerName = Application.StartupPath + "\0865059_0865125_QuanLiHocSinh.mdb"
                '.UserID = "" 
                '.Password = "" 
                '.DatabaseName = "" 
            End With
            tbCurrent.ApplyLogOnInfo(tliCurrent)
        Next tbCurrent
        'Truyền tham số vào báo cáo: Mã lớp và tên lớp
        bc.SetParameterValue("Para_MaLop", cboLop.SelectedValue)
        bc.SetParameterValue("Para_TenLop", cboLop.Text)
        bc.SetParameterValue("Para_MaMon", cboMon.SelectedValue)
        bc.SetParameterValue("Para_TenMon", cboMon.Text.ToUpper)
        bc.SetParameterValue("Para_MaHocKy", cboHocKy.SelectedValue)
        bc.SetParameterValue("Para_HocKy", cboHocKy.Text)
        'Khởi tạo màn hình hiển thị báo cáo
        Dim mh As New MH_InBaoCao()
        mh.crvBaoCao.ReportSource = bc
        mh.Show()

        Me.Close()
    End Sub
End Class